var __extends = this.__extends || function (d, b) {
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var Index = (function (_super) {
    __extends(Index, _super);
    function Index() {
        _super.apply(this, arguments);

    }
    Index.prototype.Ready = function () {
        this.SetWall();
        this.initKeyPoints();
    };
    Index.prototype.SetWall = function () {
        $.get(this.aUrl[2], {
        }, function (html) {
            $.template("WallTemplate", html);
            $("#WallList").unlimitedscroll(Base.Page.Self.aUrl[0], function (data) {
                return Base.Page.Self.WallItem(data);
            }, {
                on_complete: Base.Page.Self.CBRefreshWall,
                pageSize: 7,
                timer: 60000,
                timerUrl: Base.Page.Self.aUrl[1],
                IndexFieldName: "Date",
                on_loading: function () {
                    BlockUi('body');
                },
                on_loaded: function () {
                    $("body").unblock();
                }
            });
        });
    };
    Index.prototype.WallItem = function (data) {
        if(data) {
            var t = $("<div></div>");
            $.tmpl("WallTemplate", data).appendTo(t);
            return t;
        }
        return null;
    };
    Index.prototype.CBRefreshWall = function () {
        $('abbr.timeago').timeago();
        $(".WCDC").button({
            icons: {
                primary: "ui-icon-trash"
            },
            text: false
        });
    };
    Index.prototype.initKeyPoints = function () {
        this.loadKeyPoints();
        window.setInterval(function () {
            Base.Page.Self.loadKeyPoints();
        }, 240000);
    };
    Index.prototype.loadKeyPoints = function () {
        $.getJSON(this.aUrl[3], {
        }, function (data) {
            if(data) {
                $("#sprintName").empty().text(data.SprintName);
                $("#sprintGap").empty().text(data.SprintGap);
                if(data.KanbanIpMax && data.KanbanIpMax != null) {
                    $("#kanbanipmax").empty().text('(' + data.KanbanIpMax + ')');
                }
                if(data.KanbanTtMax && data.KanbanTtMax != null) {
                    $("#kanbanttmax").empty().text('(' + data.KanbanTtMax + ')');
                }
                LoadHtmlAndTemplate(Base.Page.Self.aUrl[4], Base.Page.Self.options.elemProjectPoints, data.Projects, true);
                LoadHtmlAndTemplate(Base.Page.Self.aUrl[5], Base.Page.Self.options.elemWdw, data.WhoDoesWhat, true);
                LoadHtmlAndTemplate(Base.Page.Self.aUrl[6], Base.Page.Self.options.elemKeys, data.KeyIndicators, true);
                if(data.ReleaseBugslist && data.ReleaseBugslist.length > 0) {
                    LoadHtmlAndTemplate(Base.Page.Self.aUrl[9], Base.Page.Self.options.elemReleaseBugList, data.ReleaseBugslist, true, function () {
                        $("#gl" + Base.Page.Self.options.elemReleaseBugList).show("fadein");
                        $('#' + Base.Page.Self.options.elemReleaseBugList + '>.accent-bg').each(function () {
                            $(this).removeClass('accent-bg').addClass('bg-color-yellow');
                        });
                    });
                } else {
                    $("#gl" + Base.Page.Self.options.elemReleaseBugList).hide();
                }
                if(data.Bugslist && data.Bugslist.length > 0) {
                    LoadHtmlAndTemplate(Base.Page.Self.aUrl[9], Base.Page.Self.options.elemBugsList, data.Bugslist, true, function () {
                        $("#gl" + Base.Page.Self.options.elemBugsList).show("fadein");
                    });
                } else {
                    $("#gl" + Base.Page.Self.options.elemBugsList).hide();
                }
                Base.Page.Self.InitGraph(data);
            }
        });
    };
    Index.prototype.OpenCommentDiaglog = function (id) {
        $("#comment").val("");
        $('#dialog-comments').dialog({
            autoOpen: false,
            width: 400,
            modal: true,
            buttons: {
                Cancel: function () {
                    $(this).dialog("close");
                },
                "Add": function () {
                    $.getJSON(this.aUrl[7], {
                        id: id,
                        comment: $("#comment").val(),
                        mail: $("#mail").val()
                    }, function (data) {
                        if(data && data[0]) {
                            $("#WallList").refresh();
                        }
                    });
                    $(this).dialog("close");
                }
            }
        }).dialog('open');
    };
    Index.prototype.DeleteComment = function (id) {
        $.getJSON(this.aUrl[8], {
            id: id
        }, function (data) {
            if(data) {
                $("#WallList").refresh();
            }
            return true;
        });
        return false;
    };
    Index.prototype.InitGraph = function (data) {
        if(data && data.BurnDown) {
            this.bdgchart = new Highcharts.Chart({
                chart: {
                    renderTo: 'bdGrph',
                    height: 200,
                    borderRadius: 0,
                    backgroundColor: '#FFF'
                },
                legend: {
                    enabled: false
                },
                credits: {
                    enabled: false
                },
                colors: [
                    '#24A0DA', 
                    '#CD4900', 
                    '#89A54E', 
                    '#80699B', 
                    '#3D96AE', 
                    '#DB843D', 
                    '#92A8CD', 
                    '#A47D7C', 
                    '#B5CA92'
                ],
                xAxis: {
                    min: 0,
                    max: data.BurnDown.XAxis[0],
                    tickInterval: 1,
                    plotBands: [
                        {
                            from: 0,
                            to: data.BurnDown.XAxis[1],
                            color: 'rgba(68, 170, 213, .2)'
                        }
                    ]
                },
                yAxis: {
                    min: 0,
                    max: data.BurnDown.IdealBurnDown[0] + 2,
                    endOnTick: false,
                    tickInterval: data.BurnDown.YAxis[1],
                    title: {
                        text: null
                    }
                },
                title: {
                    text: null
                },
                series: [
                    {
                        type: 'line',
                        name: 'Working Days',
                        data: [
                            [
                                0, 
                                data.BurnDown.IdealBurnDown[0]
                            ], 
                            [
                                data.BurnDown.XAxis[0], 
                                0
                            ]
                        ],
                        marker: {
                            enabled: false,
                            radius: 4
                        },
                        states: {
                            hover: {
                                lineWidth: 0
                            }
                        },
                        enableMouseTracking: false
                    }, 
                    {
                        type: 'spline',
                        name: 'Remain points',
                        data: data.BurnDown.RealBurnDown,
                        marker: {
                            enabled: true,
                            radius: 4
                        }
                    }
                ]
            });
        }
    };
    return Index;
})(Base.Page);
//@ sourceMappingURL=Index.js.map
